package com.bootssm.service.impl;

import com.bootssm.dao.FinanceMapper;
import com.bootssm.entity.Finance;
import com.bootssm.entity.FinanceVO;
import com.bootssm.service.FinanceService;
import com.bootssm.utils.IdWorker;
import com.bootssm.utils.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class FinanceServiceImpl implements FinanceService {

    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    @Autowired
    FinanceMapper financeMapper;
    @Autowired
    IdWorker idWorker;
    @Override
    public List<Finance> findAll(FinanceVO financeVO) {
        return financeMapper.findAll(financeVO);
    }

    @Override
    public Integer getCount(FinanceVO financeVO) {
        return financeMapper.getCount(financeVO);
    }

    @Override
    public void deleteById(String id) {
        financeMapper.deleteById(id);
    }

    @Override
    public void update(Finance finance) {
        financeMapper.update(finance);
    }

    @Override
    public void save(Finance finance) {
        String l = String.valueOf(idWorker.nextId());
        finance.setCountid(l);
        finance.setCreatedates(TimeUtil.getCurrentTime(new Date()));
        financeMapper.save(finance);
    }
}
